package cn.com.nes.site.action.crm;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.nes.common.util.DBUtils;
import cn.com.nes.site.entity.DataReq;
import cn.com.nes.site.entity.DataRes;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.module.service.crm.AnalysisOppService;

@Controller("analysisOpp")
@RequestMapping("/analysisOpp")
public class AnalysisoOppAction {
	
	@Resource
	private AnalysisOppService service;
	
	//查询线索列表
	@RequestMapping(method = RequestMethod.POST, value = "/getTotalOpportunity")
	public @ResponseBody  PageData getTotalOpportunity(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getTotalOpportunity(req) ;
			return res;
	}
	
	//商机各阶段分析
	@RequestMapping(method = RequestMethod.POST, value = "/getOpportunityStagePercentage")
	public @ResponseBody  PageData getOpportunityStagePercentage(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getOpportunityStagePercentage(req) ;
			return res;
	}
	
	//商机转化率
	@RequestMapping(method = RequestMethod.POST, value = "/getOpportunityConversionRate")
	public @ResponseBody  PageData getOpportunityConversionRate(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getOpportunityConversionRate(req) ;
			return res;
	}
	
	//商机地图展示
	@RequestMapping(method = RequestMethod.POST, value = "/getOpportunityMap")
	public @ResponseBody  PageData getOpportunityMap(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getOpportunityMap(req) ;
			return res;
	}
	
	//商机占比
	@RequestMapping(method = RequestMethod.POST, value = "/getOpportunityPer")
	public @ResponseBody  PageData getOpportunityPer(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getOpportunityPer(req) ;
			return res;
	}
	
	//商机预期成交金额
	@RequestMapping(method = RequestMethod.POST, value = "/getOpportunitymoney")
	public @ResponseBody  PageData getOpportunitymoney(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getOpportunitymoney(req) ;
			return res;
	}
	
	//商机员工跟进
	@RequestMapping(method = RequestMethod.POST, value = "/getOpportunityStaffCheck")
	public @ResponseBody  PageData getOpportunityStaffCheck(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
			DataRes req_Status = DBUtils.setRemoteVisit(request, response,true);
			PageData res = new PageData() ;
			if (req_Status.getRetCode() != 0) {
				res = new PageData();
				res.setRetCode(req_Status.getRetCode()) ;
				res.setRetMessage(req_Status.getRetMessage());
				return res;
			}	
			DataReq req = req_Status.getReq() ;
			res = service.getOpportunityStaffCheck(req) ;
			return res;
	}
}
